#include "main.h"

static int touch_irq_flag = 0;

uint8_t sdspiflashsta;

uint8_t timecnt10ms, u8disp100ms, u8keychkflag;


uint32_t dispBuff[LCD_H*LCD_W] __attribute__((at(SDRAMM_BASE))) = {0x00000000};
uint32_t color = 0xf;

void user_init();
void user_loop();
void showData(){
	while(LCD_IsBusy(LCD));
	for(int h = 1;h < 271;h++){
		for(int w = 1;w < 480;w++){
			dispBuff[h*400+w/2] = color<<16|color;
		}
	}
}
//#############################################################################1
//#############################################################################1
/*-------------- Main������ʼλ ------------------*/
//#############################################################################1
int main(void)
{
	_LCD_BACKLIGHT_PORT_INIT();
	_LCD_BALKLIGHT_OFF();

	SystemInit();
	systick_init();
	SerialInit(921600);

	TIMR_Init(TIMR0, TIMR_MODE_TIMER, SystemCoreClock/1000, 1);	//ÿ1�����Ӵ���һ���ж�
	TIMR_Start(TIMR0);	
	lcd_memory_init();

	swm_delay(10);
	NVIC_EnableIRQ(LCD_IRQn);
	lcd_rgb_init();
	//								creat_mainapp();

	LCD_Start(LCD);
	
	for(int h = 0;h < LCD_H*2;h++){
		for(int w = 0;w < LCD_W/2;w++){
			dispBuff[h*(LCD_W/2)+w] = 0;
		}
	}
	LCD->SRCADDR = (uint32_t)dispBuff;
	SPI_Flash_Init();
	user_init();
    while (1 == 1)
    {
		user_loop();
    }
}



//===================================================================2
//===================================================================2
void SysTick_Handler_cb(void)
{
    
}


//-----------------------------------------------4
void TIMR0_Handler(void)
{
	TIMR_INTClr(TIMR0);
	
	timecnt10ms ++;
	
	if ((timecnt10ms%10) == 0)
		u8keychkflag = 1;
	if (timecnt10ms > 100)
	{
		timecnt10ms = 0;
		u8disp100ms = 1;
	}
}

